<div class="content-section introduction">
    <div class="feature-intro">
        <h1>TabMenu</h1>
        <p>TabMenu is a navigation component that displays items as tab headers. Example below uses nested routes with TabMenu.</p>
    </div>
    <app-demoActions github="tabmenu" stackblitz="tabmenu-demo"></app-demoActions>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Default</h5>
        <p-tabMenu [model]="items" [activeItem]="activeItem"></p-tabMenu>
    </div>

    <div class="card">
        <h5>Scrollable</h5>
        <p-tabMenu [scrollable]="true" [model]="scrollableItems" [activeItem]="activeItem2"></p-tabMenu>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;TabMenuModule&#125; from 'primeng/tabmenu';
import &#123;MenuItem&#125; from 'primeng/api';
</app-code>

            <h5>MenuModel API</h5>
            <p>TabMenu uses the common menumodel api to define its items, visit <a [routerLink]="['/menumodel']">MenuModel API</a> for details.</p>

            <h5>Getting Started</h5>
            <p>TabMenu requires a collection of menuitems as its <i>model</i>.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-tabMenu [model]="items"&gt;&lt;/p-tabMenu&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class TabMenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [
            &#123;label: 'Home', icon: 'pi pi-fw pi-home'&#125;,
            &#123;label: 'Calendar', icon: 'pi pi-fw pi-calendar'&#125;,
            &#123;label: 'Edit', icon: 'pi pi-fw pi-pencil'&#125;,
            &#123;label: 'Documentation', icon: 'pi pi-fw pi-file'&#125;,
            &#123;label: 'Settings', icon: 'pi pi-fw pi-cog'&#125;
        ];
    &#125;
&#125;
</app-code>

            <h5>ActiveItem</h5>
            <p>By default item that matches the active route is highlighted, alternatively <i>activeItem</i> property can be used choose the initial active item.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-tabMenu [model]="items" [activeItem]="items[0]"&gt;&lt;/p-tabMenu&gt;
</app-code>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class TabMenuDemo &#123;
    
    items: MenuItem[];
    
    activeItem: MenuItem;

    ngOnInit() &#123;
        this.items = [
            &#123;label: 'Home', icon: 'pi pi-fw pi-home'&#125;,
            &#123;label: 'Calendar', icon: 'pi pi-fw pi-calendar'&#125;,
            &#123;label: 'Edit', icon: 'pi pi-fw pi-pencil'&#125;,
            &#123;label: 'Documentation', icon: 'pi pi-fw pi-file'&#125;,
            &#123;label: 'Settings', icon: 'pi pi-fw pi-cog'&#125;
        ];
        
        this.activeItem = this.items[0];
    &#125;
&#125;
</app-code>

            <h5>Templating</h5>
            <p>Menuitem content supports templating via the "item" template which gets the menuitem instance and the index.</p>
            <app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
&lt;p-tabMenu [model]="items"&gt;
    &lt;ng-template pTemplate="item" let-item let-i="index"&gt;
        //item content
    &lt;/ng-template&gt;
&lt;/p-tabMenu&gt;
</app-code>

<h5>Scrollable</h5>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-tabMenu [model]="scrollableItems" [activeItem]="activeItem2"&gt;&lt;/p-tabMenu&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class TabMenuDemo &#123;

    scrollableItems: MenuItem[];

    activeItem2: MenuItem;

    ngOnInit() &#123;
        this.scrollableItems = Array.from(&#123; length: 50 &#125;, (_, i) => (&#123; label: `Tab $&#123;i + 1&#125;`, icon: `pi pi-fw pi-display` &#125;));
        this.activeItem2 = this.scrollableItems[0];
    &#125;
&#125;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Default</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>model</td>
                            <td>array</td>
                            <td>null</td>
                            <td>An array of menuitems.</td>
                        </tr>
                        <tr>
                            <td>activeItem</td>
                            <td>MenuItem</td>
                            <td>null</td>
                            <td>Defines the default active menuitem</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>scrollable</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When enabled displays buttons at each side of the tab headers to scroll the tab list.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Templates of TabPanel</h5>
            <div class="doc-tablewrapper">
               <table class="doc-table">
                     <thead>
                        <tr>
                           <th>Name</th>
                           <th>Parameters</th>
                        </tr>
                     </thead>
                     <tbody>
                        <tr>
                           <td>item</td>
                           <td>$implicit: Data of the menu item <br />
                            index: Index of the option</td>
                        </tr>
                     </tbody>
               </table>
            </div>
            
            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-tabmenu</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-tabmenu-nav</td>
                            <td>List element of headers.</td>
                        </tr>
                        <tr>
                            <td>p-tabmenuitem</td>
                            <td>Menuitem element.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem-link</td>
                            <td>Link inside a menuitem.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem-text</td>
                            <td>Label of a menuitem.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem-icon</td>
                            <td>Icon of a menuitem.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/tabmenu" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-tabmenu-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-tabMenu [model]="items" [activeItem]="activeItem"&gt;&lt;/p-tabMenu&gt;

&lt;p-tabMenu [model]="scrollableItems" [scrollable]="true" [activeItem]="activeItem2"&gt;&lt;/p-tabMenu&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class TabMenuDemo &#123;
    
    items: MenuItem[];

    scrollableItems: MenuItem[];

    activeItem: MenuItem;

    activeItem2: MenuItem;

    ngOnInit() &#123;
        this.items = [
            &#123;label: 'Home', icon: 'pi pi-fw pi-home'&#125;,
            &#123;label: 'Calendar', icon: 'pi pi-fw pi-calendar'&#125;,
            &#123;label: 'Edit', icon: 'pi pi-fw pi-pencil'&#125;,
            &#123;label: 'Documentation', icon: 'pi pi-fw pi-file'&#125;,
            &#123;label: 'Settings', icon: 'pi pi-fw pi-cog'&#125;
        ];

        this.scrollableItems = Array.from(&#123; length: 50 &#125;, (_, i) => (&#123; label: `Tab $&#123;i + 1&#125;`&#125;));

        this.activeItem = this.items[0];

        this.activeItem2 = this.scrollableItems[0];
    &#125;

&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-tabmenu-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
